// Include system file
#include "r_cg_can.h"

// Include project file
#include "CAN.h"
#include "fet.h"
#include "nvm.h"
#include "control.h"
#include "faults.h"
#include "Main.h"
#include "Switches.h"
#include "Joystick.h"
#include "Serial.h"
#include "Battery.h"
#include "BMS_CAN.h"

#include "RangeExtender.h"
#include "RemoteCtrlCan.h"
#include "MotoCan.h"
/*

typedef struct
{
	UINT8 Bytes[8];
	struct
	{

	}bit;
}structStreerMotoCan;
typedef struct
{
	UINT8 Bytes[8];
	struct
	{

	}bit;
}structPumpMotoCan;
*/
typedef struct
{
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16SpeedRef;
			/*
			bit0:电源使能
			bit1:接触器使能
			bit2:刹车使能
			bit3:前进
			bit4:后退
			*/
			UINT8 fPowerEn:1;
			UINT8 fRelayEn:1;
			UINT8 fBrakeEn:1;
			UINT8 fForward:1;
			UINT8 fBackward:1;
			UINT8 u8Byte2NC:3;

			UINT8 u8Byte3NC1:4;
			UINT8 fReleaseBrake:1;
			UINT8 u8Byte3NC2:3;

			UINT8 BytesNC[4];
		}bit;
	}unTx20x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16SpeedFbk;
			UINT8 BytesNC[5];
			UINT8 u8PhaseCurrent;
		}bit;
	}unRx18x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT8 u8ErrCode;
			UINT8 Byte1NC;
			UINT8 u8MotoTemp;
			INT8 s8CtrlTemp;
			UINT8 u8BDI;
			INT8 s8AvrCurrent;
			UINT16 u16BattVoltage;
		}bit;
	}unRx28x;
}structWalkMotoCan;
typedef struct
{
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16AngleRef;
			/*
			bit0:电源使能
			bit1:接触器使能
			bit2:刹车使能
			bit3:前进
			bit4:后退
			*/
			UINT8 fPowerEn:1;
			UINT8 fRelayEn:1;
			UINT8 fBrakeEn:1;
			UINT8 fForward:1;
			UINT8 fBackward:1;
			UINT8 u8Byte2NC:3;

			UINT8 BytesNC[4];
		}bit;
	}unTx20x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 u16AngleFbk;
			UINT16 u16Speed;
			UINT8 BytesNC[3];
			UINT8 u8PhaseCurrent;
		}bit;
	}unRx18x;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT8 u8ErrCode;
			UINT8 u8Byte1NC;
			UINT8 u8MotoTemp;
			INT8 s8CtrlTemp;
			UINT8 u8BDI;
			INT8 s8AvrCurrent;
			UINT16 u16BattVoltage;
		}bit;
	}unRx28x;
}structStreerMotoCan;
typedef struct
{
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT16 U16SpeedRef;
			
			UINT8 u8PowerEn:1;
			UINT8 u8RelayEn:1;
			UINT8 u8Byte2NC:6;

			UINT8 Bytes[5];
		}bit;
	}unTx20A;
	union
	{
		UINT8 Bytes[8];
		struct
		{
			UINT8 u8ErrCode;
			UINT8 BytesNc[2];

			INT8 s8CtrlTemp;
			UINT8 u8BDI;
			INT8 s8AvrCurrent;
			UINT16 u16BattVoltage;
		}bit;
	}unRx28A;
}structPumpMotoCan;




